


 import { Message, MessageBox } from 'element-ui'
 import store from '@/store'
 import router from '@/router'
// 新窗口打开bpm -- 可自动关闭
export function newWindowBpm (processInstId,type,pushParams=null,noCache=false,route=null,) {
  function getPostUrl (processInstId) { // 获取地址
    let portUrl = ''
    let isTest = process.env.NODE_ENV === "test" || process.env.NODE_ENV === "development"
    if (isTest){// 是测试版
      portUrl = 'http://bpmuat.zberpnc.com/portal/r/w?cmd=com.zb.common.sso_openForm'
    }else{// 是正式版
      portUrl = 'http://pal.zhengbang.com/portal/r/w?cmd=com.zb.common.sso_openForm'
      //portUrl = 'http://bpmuat.zberpnc.com/portal/r/w?cmd=com.zb.common.sso_openForm'
    }
    let oaNumber = store.state.user.account; // oa号
    return portUrl + '&processInstId=' + processInstId + '&uid=' + oaNumber + '&ismobile=false' + '&ssoLogin=true'
  }

  function open(urls){
    window.open(`${urls}`, '_blank', `height=${screen.height}, width=${screen.width + 20},scrollbars=yes,resizable=1,modal=false,alwaysRaised=yes`);
  }

  if(type){
    open(getPostUrl(processInstId))
    return false
  }

  MessageBox.confirm('成功,即将进入bpm', '提示', {
    confirmButtonText: '确定',
    showCancelButton:false,
    showClose:false,
    closeOnClickModal:false,
    closeOnPressEscape:false,
    type: 'warning'
  }).then(() => {
    open(getPostUrl(processInstId))
    if (pushParams){
      if (noCache) {
        store.dispatch('tagsView/delCachedView', route)
          .then(() => {
            router.push(pushParams)
          })
      }else{
        router.push(pushParams)
      }
    }else{
      router.go(-1)
    }
  }).catch(() => {

  });



}
